package com.example.intelglasses;

public class JudgeVoice {

	/**
	 * 信号发生器界面的声音识别
	 * 
	 * @param tempstr
	 * @return 1:切换到示波器 2:切换到数据查询 3:开启信号/关闭信号 4:开启锯齿波 5:开启方波 6:开启正弦波 10:建立连接
	 *         11:结束程序
	 */
	public static int returnSignal(String tempstr) {
		int revalue = 0;
		switch (tempstr.substring(0, 2)) {
		case "示波":
			revalue = 1;
			break;
		case "查询":
			revalue = 2;
			break;
		case "数据":
			revalue = 2;
			break;
		case "记录":
			revalue = 2;
			break;
		case "开启":
			revalue = 3;
			break;
		case "关闭":
			revalue = 3;
			break;
		case "锯齿":
			revalue = 4;
			break;
		case "三角":
			revalue = 4;
			break;
		case "方波":
			revalue = 5;
			break;
		case "正弦":
			revalue = 6;
			break;
		case "曲线":
			revalue = 6;
			break;
		case "连接":
			revalue = 10;
			break;
		case "退出":
			revalue = 11;
			break;
		case "拜拜":
			revalue = 11;
			break;
		default:
			revalue = 0;
			break;
		}
		if (revalue == 0) {
			switch (tempstr.substring(0, 1)) {
			case "示":
				revalue = 1;
				break;
			case "查":
				revalue = 2;
				break;
			case "记":
				revalue = 2;
				break;
			case "开":
				revalue = 3;
				break;
			case "关":
				revalue = 3;
				break;
			case "锯":
				revalue = 4;
				break;
			case "三":
				revalue = 4;
				break;
			case "方":
				revalue = 5;
				break;
			case "正":
				revalue = 6;
				break;
			case "曲":
				revalue = 6;
				break;
			case "退":
				revalue = 11;
				break;
			default:
				revalue = 0;
				break;
			}
		}
		return revalue;
	}

	/** 示波器界面的声音识别 */
	public static int returnOSC(String tempstr) {
		int revalue = 0;
		switch (tempstr.substring(0, 2)) {
		case "信号":
			revalue = 1;
			break;
		case "函数":
			revalue = 1;
			break;
		case "查询":
			revalue = 2;
			break;
		case "记录":
			revalue = 2;
			break;
		case "数据":
			revalue = 2;
			break;
		case "开启":
			revalue = 10;
			break;
		case "关闭":
			revalue = 10;
			break;
		case "连接":
			revalue = 10;
			break;
		case "邻居":
			revalue = 10;
			break;
		case "断开":
			revalue = 10;
			break;
		case "退出":
			revalue = 11;
			break;
		case "拜拜":
			revalue = 11;
			break;
		case "保存":
			revalue = 12;
			break;
		default:
			revalue = 0;
			break;
		}
		if (revalue == 0) {
			switch (tempstr.substring(0, 1)) {
			case "信":
				revalue = 1;
				break;
			case "函":
				revalue = 1;
				break;
			case "查":
				revalue = 2;
			case "记":
				revalue = 2;
				break;
			case "开":
				revalue = 10;
				break;
			case "关":
				revalue = 10;
				break;
			case "断":
				revalue = 10;
				break;
			case "退":
				revalue = 11;
				break;
			case "保":
				revalue = 12;
				break;
			case "通":
				revalue = 23;
				break;
			default:
				revalue = 0;
				break;
			}
		}
		if (revalue == 23) {
			if (tempstr.substring(0, 3).equals("通道一")) {
				revalue = 21;
			} else {
				revalue = 22;
			}
		}
		return revalue;
	}

	/** 数据查询界面的声音识别 */
	public static int returnQuery(String tempstr) {
		int revalue = 0;
		switch (tempstr.substring(0, 2)) {
		case "信号":
			revalue = 1;
			break;
		case "函数":
			revalue = 1;
			break;
		case "示波":
			revalue = 2;
			break;
		case "退出":
			revalue = 11;
			break;
		case "拜拜":
			revalue = 11;
			break;
		case "下一":
			revalue = 31;
			break;
		case "上一":
			revalue = 32;
			break;
		default:
			revalue = 0;
			break;
		}
		if (revalue == 0) {
			switch (tempstr.substring(0, 1)) {
			case "信":
				revalue = 1;
				break;
			case "函":
				revalue = 1;
				break;
			case "示":
				revalue = 2;
				break;
			case "退":
				revalue = 11;
				break;
			case "通":
				revalue = 23;
				break;
			case "下":
				revalue = 31;
				break;
			case "上":
				revalue = 32;
				break;
			default:
				revalue = 0;
				break;
			}
		}
		if (revalue == 23) {
			if (tempstr.substring(0, 3).equals("通道一")) {
				revalue = 21;
			} else {
				revalue = 22;
			}
		}
		return revalue;
	}

}

